﻿IF EXISTS(SELECT * FROM sys.databases where Name = '$(dbname)')
BEGIN
	PRINT N'Dropping the existing database'
	ALTER DATABASE $(dbname) SET SINGLE_USER WITH ROLLBACK IMMEDIATE	
	DROP DATABASE $(dbname)
END
GO

IF NOT EXISTS(SELECT * FROM sys.databases where Name = '$(dbname)')
BEGIN
	CREATE DATABASE $(dbname)
	PRINT N'Waiting for meterialization...'
	WAITFOR DELAY '00:00:15'
END
GO

use $(dbname)
